<script>
	export default {
		onLaunch: function() {
			console.log('App Launch');
			// 检查登录状态
			const token = uni.getStorageSync('token');
			if (!token) {
				// 未登录，跳转到登录页
				uni.reLaunch({
					url: '/pages/login/login'
				});
				return;
			}
		},
		onShow: function() {
			console.log('App Show');
			// 每次显示应用时都检查登录状态
			const token = uni.getStorageSync('token');
			if (!token) {
				uni.reLaunch({
					url: '/pages/login/login'
				});
				return;
			}
		},
		onHide: function() {
			console.log('App Hide');
		},
		methods: {
			isTabbarPage() {
				const pages = getCurrentPages();
				if (pages.length === 0) return true;
				
				const currentRoute = pages[pages.length - 1].route;
				const tabbarPages = ['pages/index/index', 'pages/publish/publish', 'pages/user/user'];
				
				return tabbarPages.includes(currentRoute);
			}
		}
	}
</script>

<style>
	/* 全局样式 */
	page {
		font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
		font-size: 28rpx;
		color: #333;
		background-color: #f7f7f7;
		background-image: linear-gradient(135deg, #f7f9fe, #eef2f9);
	}
	
	/* 解决小程序文字溢出问题 */
	text {
		word-break: break-all;
	}
	
	/* 清除按钮默认样式 */
	button {
		background-color: transparent;
		padding: 0;
		margin: 0;
		line-height: normal;
	}
	
	button::after {
		border: none;
	}
	
	/* 添加字体图标支持 */
	.iconfont {
		font-family: "iconfont";
	}
	
	.icon-like:before {
		content: "♥";
	}
	
	.icon-comment:before {
		content: "✉";
	}
	
	.icon-add:before {
		content: "+";
	}
	
	.icon-edit:before {
		content: "✎";
	}
	
	.icon-delete:before {
		content: "✕";
	}
	
	/* 琉璃态公共样式 */
	.glassmorphism {
		background-color: rgba(255, 255, 255, 0.7);
		backdrop-filter: blur(10px);
		-webkit-backdrop-filter: blur(10px);
		border-radius: 16rpx;
		border: 1rpx solid rgba(255, 255, 255, 0.2);
		box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
	}
	
	/* 按钮动效 */
	.btn-effect {
		transition: all 0.3s ease;
	}
	
	.btn-effect:active {
		transform: scale(0.98);
		opacity: 0.9;
	}
	
	/* 渐变按钮 */
	.gradient-btn {
		background: linear-gradient(135deg, #3b91d9, #0064c8);
		color: #fff;
		border-radius: 45rpx;
		box-shadow: 0 8rpx 20rpx rgba(0, 122, 255, 0.25);
		border: 1rpx solid rgba(255, 255, 255, 0.3);
	}
	
	/* 阴影效果 */
	.shadow {
		box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
	}
</style>
